﻿//MIRIAN
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Upeu.Venta.Data.Entities;

namespace Upeu.Venta.Data.Mappings
{
    public class VentasMap : EntityTypeConfiguration<Ventas>
    {
        public VentasMap()
        {
            //cambiar nombre table
            ToTable("Ventas");

            //pk
            HasKey(v => v.IdVentas);
            Property(v => v.IdVentas)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);

            //campos
            Property(v => v.FechaVenta).IsOptional();
            Property(v => v.NumDoc).IsOptional();
            Property(v => v.Serie).IsRequired();

            this.HasRequired(v => v.Trabajador)
                .WithMany(v => v.Ventasss)
                .HasForeignKey(v => v.IdTrabajador);

        }
    }
}

